<template>
  <el-dialog
    title="选择审核人员"
    :visible.sync="SelectPersonnelData.dialogReview"
    width="40%"
    append-to-body
  >
    <el-tree
      ref="tree"
      :data="reviewData"
      default-expand-all
      highlight-current
      :show-checkbox="true"
      :check-strictly="true"
      node-key="id"
      @check-change="handleClick"
    />
    <span slot="footer" class="dialog-footer">
      <el-button
        class="buttonleft"
        @click="SelectPersonnelData.dialogReview = false"
        >取消</el-button
      >
      <el-button type="primary" class="buttonright" @click="Review"
        >确定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
import { getsearch } from '@/api/uc/search'
import { pushQa } from '@/api/mes/manufactureOrder.js'
export default {
  props: ['SelectPersonnelData'],
  data() {
    return {
      reviewData: '',
      qauserId: '',
      manufactureArchiveId: ''
    }
  },
  watch: {
    SelectPersonnelData(val) {
      this.manufactureArchiveId = val.manufactureArchiveId
    }
  },
  mounted() {
    this.getsearch()
  },
  methods: {
    // 获取数据
    async getsearch() {
      let data = await getsearch()
      let reviewData = data.data.groupUserTree
      reviewData.forEach((node) => {
        node.disabled = true
      })
      this.reviewData = reviewData
    },

    handleClick(data, checked, node) {
      if (checked) {
        console.log(data, 'data')
        this.qauserId = data.id
        //关键
        this.$refs.tree.setCheckedNodes([data])
      }
    },
    Review() {
      this.SelectPersonnelData.dialogReview = false
      let data = {
        qauserId: this.qauserId,
        manufactureArchiveId: this.manufactureArchiveId
      }
      pushQa(data).then((res) => {
       if(res.code==1){
         this.$message.success('提交成功')
         this.$emit('statusMessage',res.code)
       }
      })
    }
  }
}
</script>

<style>
</style>